import http from '@/utils/http'
// 获取面试技巧列表
function getTechnic ({ start, limit, q }) {
  return http({
    url: '/articles/technic',
    method: 'get',
    params: {
      start,
      limit,
      q
    },
    needToken: true
  })
}
// 获取面经分享列表
function getShare ({ start, limit, q }) {
  return http({
    url: '/articles/share',
    method: 'get',
    params: {
      start,
      limit,
      q
    },
    needToken: true
  })
}
// 获取热门数据
function getHot () {
  return http({
    url: '/chart-data/hot',
    method: 'get'
  })
}
// 获取热门搜索
function apiShareTopSearch () {
  return http({
    url: '/articles/shareTopSearch'
  })
}
// 获取面经详情
function apiGetShareArticles (id) {
  return http({
    url: `/articles/share/${id}`
  })
}
// 获取面经评论
function apiGetComment ({ id, limit, start }) {
  return http({
    url: `/articles/comments/${id}`,
    params: {
      limit,
      start
    }
  })
}
// 发表评论
function apiSendComment ({ content, article, parent }) {
  return http({
    url: '/articles/comments',
    method: 'post',
    data: {
      content,
      article,
      parent
    },
    needToken: true
  })
}
// 点赞
function apiSetStar (id) {
  return http({
    url: '/articles/star',
    method: 'post',
    data: {
      article: id
    },
    needToken: true
  })
}
// 收藏
function apiSetCollect (id) {
  return http({
    url: '/articles/collect',
    method: 'post',
    data: {
      id
    },
    needToken: true
  })
}
export {
  getTechnic,
  getShare,
  getHot,
  apiShareTopSearch,
  apiGetShareArticles,
  apiGetComment,
  apiSendComment,
  apiSetStar,
  apiSetCollect
}
